<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>构造函数</title>

    <script>
        function hero(name, type, health, way) {
            this.health = health;
            this.type = type;
            this.way = way;
            this.name = name;
            this.Jn = function(name) {
                alert(name);
            }
        }

        var a = new hero('后裔', '射手型', 100, '远程');
        var b = new hero('廉颇', '力量型', 500, '近战');
        a.Jn('大鸟');
        b.Jn('泰山压顶');
        console.log(a.health, a.name, a.way, a.type);
        console.log(b.health, b.name, b.way, b.type);
    </script>


</head>

<body>

</body>

</html>